home *** CD-ROM | disk | FTP | other *** search
/ Macintosh Technology Seed 1996 September / Macintosh Technology Seed (September 1996) (CDRM1437020).ISO / pc / qd3d15d6 / 15d6_sdk.exe / QD3D Win32 1.5d6 / Interfaces / QD3DGroup.h < prev    next >
C/C++ Source or Header  |  1996-08-21  |  15KB  |  485 lines

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DGroup.h                                                 **
  4.  **                                                                             **
  5.  **                                                                             **
  6.  **     Purpose:    Group definitions and routines                             **
  7.  **                                                                             **
  8.  **                                                                             **
  9.  **                                                                             **
  10.  **     Copyright (C) 1992-1996 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                             **
  12.  **                                                                             **
  13.  *****************************************************************************/
  14. #ifndef QD3DGroup_h
  15. #define QD3DGroup_h
  16.  
  17. #if defined(PRAGMA_ONCE) && PRAGMA_ONCE
  18.     #pragma once
  19. #endif  /*  PRAGMA_ONCE  */
  20.  
  21. #if defined(THINK_C) || defined(__SC__)
  22.     #pragma options(!pack_enums, !align_arrays)
  23.     #pragma SC options align=power
  24. #elif defined(__MWERKS__)
  25.     #pragma enumsalwaysint on
  26.     #pragma align_array_members off
  27.     #pragma options align=native
  28. #elif defined(__PPCC__)
  29.     #pragma options align=power
  30. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  31.     #pragma options enum=int
  32. #endif
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif /*  __cplusplus  */
  37.  
  38.  
  39. /******************************************************************************
  40.  **                                                                             **
  41.  **                            Group Typedefs                                     **
  42.  **                                                                             **
  43.  *****************************************************************************/
  44.  
  45. /*
  46.  * These flags affect how a group is traversed
  47.  * They apply to when a group is "drawn", "picked", "bounded", "written"
  48.  */
  49. typedef enum TQ3DisplayGroupStateMasks {
  50.     kQ3DisplayGroupStateNone                    = 0,
  51.     kQ3DisplayGroupStateMaskIsDrawn                = 1 << 0,
  52.     kQ3DisplayGroupStateMaskIsInline            = 1 << 1,
  53.     kQ3DisplayGroupStateMaskUseBoundingBox        = 1 << 2,
  54.     kQ3DisplayGroupStateMaskUseBoundingSphere    = 1 << 3,
  55.     kQ3DisplayGroupStateMaskIsPicked            = 1 << 4,
  56.     kQ3DisplayGroupStateMaskIsWritten            = 1 << 5
  57. } TQ3DisplayGroupStateMasks;
  58.  
  59. typedef unsigned long TQ3DisplayGroupState;
  60.  
  61. /******************************************************************************
  62.  **                                                                             **
  63.  **                    Group Routines (apply to all groups)                     **
  64.  **                                                                             **
  65.  *****************************************************************************/
  66.  
  67. QD3D_EXPORT TQ3GroupObject Q3Group_New(        /* May contain any shared object */
  68.     void);
  69.     
  70. QD3D_EXPORT TQ3ObjectType Q3Group_GetType(
  71.     TQ3GroupObject            group);
  72.  
  73. QD3D_EXPORT TQ3GroupPosition Q3Group_AddObject(
  74.     TQ3GroupObject            group,
  75.     TQ3Object                object);
  76.     
  77. QD3D_EXPORT TQ3GroupPosition Q3Group_AddObjectBefore(
  78.     TQ3GroupObject            group,
  79.     TQ3GroupPosition        position,
  80.     TQ3Object                object);
  81.  
  82. QD3D_EXPORT TQ3GroupPosition Q3Group_AddObjectAfter(
  83.     TQ3GroupObject            group,
  84.     TQ3GroupPosition        position,
  85.     TQ3Object                object);
  86.  
  87. QD3D_EXPORT TQ3Status Q3Group_GetPositionObject(
  88.     TQ3GroupObject            group,
  89.     TQ3GroupPosition        position,    
  90.     TQ3Object                *object);        
  91.  
  92. QD3D_EXPORT TQ3Status Q3Group_SetPositionObject(
  93.     TQ3GroupObject            group,
  94.     TQ3GroupPosition        position,
  95.     TQ3Object                object);
  96.  
  97. QD3D_EXPORT TQ3Object Q3Group_RemovePosition(
  98.     TQ3GroupObject            group,
  99.     TQ3GroupPosition        position);
  100.  
  101. QD3D_EXPORT TQ3Status Q3Group_GetFirstPosition(        
  102.     TQ3GroupObject            group,
  103.     TQ3GroupPosition        *position);
  104.  
  105. QD3D_EXPORT TQ3Status Q3Group_GetLastPosition(        
  106.     TQ3GroupObject            group,
  107.     TQ3GroupPosition        *position);
  108.  
  109. QD3D_EXPORT TQ3Status Q3Group_GetNextPosition(        
  110.     TQ3GroupObject            group,
  111.     TQ3GroupPosition        *position);
  112.  
  113. QD3D_EXPORT TQ3Status Q3Group_GetPreviousPosition(        
  114.     TQ3GroupObject            group,
  115.     TQ3GroupPosition        *position);
  116.  
  117. QD3D_EXPORT TQ3Status Q3Group_CountObjects(
  118.     TQ3GroupObject            group,
  119.     unsigned long            *nObjects);
  120.  
  121. QD3D_EXPORT TQ3Status Q3Group_EmptyObjects(
  122.     TQ3GroupObject            group);
  123.     
  124. /*
  125.  *     Typed Access
  126.  */
  127. QD3D_EXPORT TQ3Status Q3Group_GetFirstPositionOfType(        
  128.     TQ3GroupObject            group,
  129.     TQ3ObjectType            isType,
  130.     TQ3GroupPosition        *position);
  131.  
  132. QD3D_EXPORT TQ3Status Q3Group_GetLastPositionOfType(        
  133.     TQ3GroupObject            group,
  134.     TQ3ObjectType            isType,
  135.     TQ3GroupPosition        *position);
  136.  
  137. QD3D_EXPORT TQ3Status Q3Group_GetNextPositionOfType(        
  138.     TQ3GroupObject            group,
  139.     TQ3ObjectType            isType,
  140.     TQ3GroupPosition        *position);
  141.  
  142. QD3D_EXPORT TQ3Status Q3Group_GetPreviousPositionOfType(        
  143.     TQ3GroupObject            group,
  144.     TQ3ObjectType            isType,
  145.     TQ3GroupPosition        *position);
  146.  
  147. QD3D_EXPORT TQ3Status Q3Group_CountObjectsOfType(
  148.     TQ3GroupObject            group,
  149.     TQ3ObjectType            isType,
  150.     unsigned long            *nObjects);
  151.  
  152. QD3D_EXPORT TQ3Status Q3Group_EmptyObjectsOfType(
  153.     TQ3GroupObject            group,
  154.     TQ3ObjectType            isType);
  155.  
  156. /*
  157.  *    Determine position of objects in a group
  158.  */
  159. QD3D_EXPORT TQ3Status Q3Group_GetFirstObjectPosition(
  160.     TQ3GroupObject            group,
  161.     TQ3Object                object,
  162.     TQ3GroupPosition        *position);
  163.     
  164. QD3D_EXPORT TQ3Status Q3Group_GetLastObjectPosition(
  165.     TQ3GroupObject            group,
  166.     TQ3Object                object,
  167.     TQ3GroupPosition        *position);
  168.  
  169. QD3D_EXPORT TQ3Status Q3Group_GetNextObjectPosition(
  170.     TQ3GroupObject            group,
  171.     TQ3Object                object,
  172.     TQ3GroupPosition        *position);
  173.     
  174. QD3D_EXPORT TQ3Status Q3Group_GetPreviousObjectPosition(
  175.     TQ3GroupObject            group,
  176.     TQ3Object                object,
  177.     TQ3GroupPosition        *position);
  178.     
  179.  
  180.  
  181.  
  182.  
  183. /******************************************************************************
  184.  **                                                                             **
  185.  **                            Group Subclasses                                 **
  186.  **                                                                             **
  187.  *****************************************************************************/
  188.  
  189. QD3D_EXPORT TQ3GroupObject Q3LightGroup_New(    /* Must contain only lights */
  190.     void);
  191.  
  192. QD3D_EXPORT TQ3GroupObject Q3InfoGroup_New(        /* Must contain only strings */
  193.     void);
  194.  
  195. /******************************************************************************
  196.  **                                                                             **
  197.  **                        Display Group Routines                                 **
  198.  **                                                                             **
  199.  *****************************************************************************/
  200.  
  201. QD3D_EXPORT TQ3GroupObject Q3DisplayGroup_New(    /* May contain only drawables*/
  202.     void);
  203.     
  204. QD3D_EXPORT TQ3ObjectType Q3DisplayGroup_GetType(
  205.     TQ3GroupObject            group);
  206.  
  207. QD3D_EXPORT TQ3Status Q3DisplayGroup_GetState(
  208.     TQ3GroupObject            group,
  209.     TQ3DisplayGroupState    *state);
  210.     
  211. QD3D_EXPORT TQ3Status Q3DisplayGroup_SetState(
  212.     TQ3GroupObject            group,
  213.     TQ3DisplayGroupState    state);
  214.  
  215. QD3D_EXPORT TQ3Status Q3DisplayGroup_Submit(
  216.     TQ3GroupObject            group, 
  217.     TQ3ViewObject            view);
  218.  
  219.  
  220. /******************************************************************************
  221.  **                                                                             **
  222.  **        Ordered Display Group                                                  **
  223.  **                                                                             **
  224.  **        Ordered display groups keep objects in order by the type of object:     **
  225.  **                                                                             **
  226.  **        1    kQ3ShapeTypeTransform                                             **
  227.  **        2    kQ3ShapeTypeStyle                                                  **
  228.  **        3    kQ3SetTypeAttribute                                                  **
  229.  **        4    kQ3ShapeTypeShader                                                  **
  230.  **        5    kQ3ShapeTypeCamera                                                  **
  231.  **        6    kQ3ShapeTypeLight                                                  **
  232.  **        7    kQ3ShapeTypeGeometry                                             **
  233.  **        8    kQ3ShapeTypeGroup                                                 **            
  234.  **        9    kQ3ShapeTypeUnknown                                                 **
  235.  **                                                                             **
  236.  **        Within a type, you are responsible for keeping things in order.         **
  237.  **                                                                             **
  238.  **        You may access and/or manipulate the group using the above types      **
  239.  **        (fast), or you may use any parent or leaf class types (slower).         **
  240.  **                                                                             **
  241.  **        Additional types will be added as functionality grows.                 **
  242.  **                                                                             **
  243.  **        The group calls which access by type are much faster for ordered     ** 
  244.  **        display group for the types above.                                     **
  245.  **                                                                             **
  246.  **        N.B. In QuickDraw 3D 1.0 Lights and Cameras are a no-op when drawn.     **
  247.  **                                                                             **
  248.  *****************************************************************************/
  249.  
  250. QD3D_EXPORT TQ3GroupObject Q3OrderedDisplayGroup_New(
  251.     void);
  252.  
  253. /******************************************************************************
  254.  **                                                                             **
  255.  **        IO Proxy Display Group                                                  **
  256.  **                                                                             **
  257.  **        IO Proxy display groups are used to place more than one              **
  258.  **        representation of an object in a metafile. For example, if you know     **
  259.  **        another program does not understand NURBPatches but does understand  **
  260.  **        Meshes, you may place a mesh and a NURB Patch in an IO Proxy Group,  **
  261.  **        and the reading program will select the desired representation.         **
  262.  **                                                                             **
  263.  **        Objects in an IO Proxy Display Group are placed in their preferred     **
  264.  **        order, with the FIRST object being the MOST preferred, the LAST      **
  265.  **        object the least preferred.                                             **
  266.  **                                                                             **
  267.  **        The behavior of an IO Proxy Display Group is that when drawn/picked/ **
  268.  **        bounded, the first object in the group that is not "Unknown" is used,**
  269.  **        and the other objects ignored.                                         **
  270.  **                                                                             **
  271.  *****************************************************************************/
  272.  
  273. QD3D_EXPORT TQ3GroupObject Q3IOProxyDisplayGroup_New(
  274.     void);
  275.  
  276. /******************************************************************************
  277.  **                                                                             **
  278.  **                        Group Extension Definitions                             **
  279.  **                                                                             **
  280.  *****************************************************************************/
  281. /*
  282.  *    Searching methods - OPTIONAL
  283.  */
  284. #define kQ3XMethodType_GroupAcceptObject                \
  285.     Q3_METHOD_TYPE('g','a','c','o')
  286. typedef TQ3Boolean (*TQ3XGroupAcceptObjectMethod)(
  287.     TQ3GroupObject        group,
  288.     TQ3Object            object);
  289.  
  290. #define kQ3XMethodType_GroupAddObject                    \
  291.     Q3_METHOD_TYPE('g','a','d','o')
  292. typedef TQ3GroupPosition (*TQ3XGroupAddObjectMethod)(
  293.     TQ3GroupObject        group,
  294.     TQ3Object            object);
  295.  
  296. #define kQ3XMethodType_GroupAddObjectBefore                \
  297.     Q3_METHOD_TYPE('g','a','o','b')
  298. typedef TQ3GroupPosition (*TQ3XGroupAddObjectBeforeMethod)(
  299.     TQ3GroupObject        group,
  300.     TQ3GroupPosition    position,
  301.     TQ3Object            object);
  302.  
  303. #define kQ3XMethodType_GroupAddObjectAfter                \
  304.     Q3_METHOD_TYPE('g','a','o','a')
  305. typedef TQ3GroupPosition (*TQ3XGroupAddObjectAfterMethod)(
  306.     TQ3GroupObject        group,
  307.     TQ3GroupPosition    position,
  308.     TQ3Object            object);
  309.  
  310. #define kQ3XMethodType_GroupSetPositionObject             \
  311.     Q3_METHOD_TYPE('g','s','p','o')
  312. typedef TQ3Status (*TQ3XGroupSetPositionObjectMethod)(
  313.     TQ3GroupObject        group,
  314.     TQ3GroupPosition    gPos,
  315.     TQ3Object            obj);
  316.  
  317. #define kQ3XMethodType_GroupRemovePosition                \
  318.     Q3_METHOD_TYPE('g','r','m','p')
  319. typedef TQ3Object (*TQ3XGroupRemovePositionMethod)(
  320.     TQ3GroupObject        group,
  321.     TQ3GroupPosition    position);
  322.  
  323. /*
  324.  *    Searching methods - OPTIONAL - default uses above methods
  325.  */
  326. #define kQ3XMethodType_GroupGetFirstPositionOfType         \
  327.     Q3_METHOD_TYPE('g','f','r','t')
  328. typedef TQ3Status (*TQ3XGroupGetFirstPositionOfTypeMethod)(
  329.     TQ3GroupObject        group,
  330.     TQ3ObjectType        isType,
  331.     TQ3GroupPosition    *gPos);
  332.  
  333. #define kQ3XMethodType_GroupGetLastPositionOfType        \
  334.     Q3_METHOD_TYPE('g','l','s','t')
  335. typedef TQ3Status (*TQ3XGroupGetLastPositionOfTypeMethod)(
  336.     TQ3GroupObject        group,
  337.     TQ3ObjectType        isType,
  338.     TQ3GroupPosition    *gPos);
  339.  
  340. #define kQ3XMethodType_GroupGetNextPositionOfType        \
  341.     Q3_METHOD_TYPE('g','n','x','t')
  342. typedef TQ3Status (*TQ3XGroupGetNextPositionOfTypeMethod)(
  343.     TQ3GroupObject        group,
  344.     TQ3ObjectType        isType,
  345.     TQ3GroupPosition    *gPos);
  346.  
  347. #define kQ3XMethodType_GroupGetPrevPositionOfType        \
  348.     Q3_METHOD_TYPE('g','p','v','t')
  349. typedef TQ3Status (*TQ3XGroupGetPrevPositionOfTypeMethod)(
  350.     TQ3GroupObject        group,
  351.     TQ3ObjectType        isType,
  352.     TQ3GroupPosition    *gPos);
  353.  
  354. #define kQ3XMethodType_GroupCountObjectsOfType            \
  355.     Q3_METHOD_TYPE('g','c','n','t')
  356. typedef TQ3Status (*TQ3XGroupCountObjectsOfTypeMethod)(
  357.     TQ3GroupObject        group,
  358.     TQ3ObjectType        isType,
  359.     unsigned long        *nObjects);
  360.  
  361. #define kQ3XMethodType_GroupEmptyObjectsOfType            \
  362.     Q3_METHOD_TYPE('g','e','o','t')
  363. typedef TQ3Status (*TQ3XGroupEmptyObjectsOfTypeMethod)(
  364.     TQ3GroupObject        group,
  365.     TQ3ObjectType        isType);
  366.  
  367. #define kQ3XMethodType_GroupGetFirstObjectPosition        \
  368.     Q3_METHOD_TYPE('g','f','o','p')
  369. typedef TQ3Status (*TQ3XGroupGetFirstObjectPositionMethod)(
  370.     TQ3GroupObject        group,
  371.     TQ3Object            object,
  372.     TQ3GroupPosition    *gPos);
  373.  
  374. #define kQ3XMethodType_GroupGetLastObjectPosition        \
  375.     Q3_METHOD_TYPE('g','l','o','p')
  376. typedef TQ3Status (*TQ3XGroupGetLastObjectPositionMethod)(
  377.     TQ3GroupObject        group,
  378.     TQ3Object            object,
  379.     TQ3GroupPosition    *gPos);
  380.  
  381. #define kQ3XMethodType_GroupGetNextObjectPosition        \
  382.     Q3_METHOD_TYPE('g','n','o','p')
  383. typedef TQ3Status (*TQ3XGroupGetNextObjectPositionMethod)(
  384.     TQ3GroupObject        group,
  385.     TQ3Object            object,
  386.     TQ3GroupPosition    *gPos);
  387.  
  388. #define kQ3XMethodType_GroupGetPrevObjectPosition        \
  389.     Q3_METHOD_TYPE('g','p','o','p')
  390. typedef TQ3Status (*TQ3XGroupGetPrevObjectPositionMethod)(
  391.     TQ3GroupObject        group,
  392.     TQ3Object            object,
  393.     TQ3GroupPosition    *gPos);
  394.  
  395. /*
  396.  *    Group Position Methods
  397.  *    
  398.  */
  399. #define kQ3XMethodType_GroupPositionSize            \
  400.     Q3_METHOD_TYPE('g','g','p','z')
  401. typedef unsigned long TQ3XMethodTypeGroupPositionSize;
  402.  
  403. #define kQ3XMethodType_GroupPositionNew                \
  404.     Q3_METHOD_TYPE('g','g','p','n')
  405. typedef TQ3Status (*TQ3XGroupPositionNewMethod)(
  406.     void                    *gPos,
  407.     TQ3Object                object,
  408.     const void                *initData);
  409.  
  410. #define kQ3XMethodType_GroupPositionCopy            \
  411.     Q3_METHOD_TYPE('g','g','p','c')
  412. typedef TQ3Status (*TQ3XGroupPositionCopyMethod)(
  413.     void                    *srcGPos,
  414.     void                    *dstGPos);
  415.  
  416. #define kQ3XMethodType_GroupPositionDelete            \
  417.     Q3_METHOD_TYPE('g','g','p','d')
  418. typedef void (*TQ3XGroupPositionDeleteMethod)(
  419.     void                    *gPos);
  420.  
  421. /*
  422.  *    View Drawing Helpers
  423.  *    
  424.  *    TQ3XGroupStartIterateMethod
  425.  *
  426.  *        Pass back *object = NULL to NOT call EndIterate iterate
  427.  *        Pass back *object != NULL to draw object
  428.  *         (other side will pass it to EndIterate for deletion!)
  429.  *
  430.  *        *iterator is uninitialized, use for iteration state. Caller should 
  431.  *         ignore it.
  432.  *    
  433.  *    TQ3XGroupEndIterateMethod
  434.  *    
  435.  *        *object is previous object, dispose it or play with it.
  436.  *        Pass back NULL when last iteration has occurred
  437.  *        *iterator is previous value, use for iteration state Caller should 
  438.  *        ignore it.
  439.  */
  440. #define kQ3XMethodType_GroupStartIterate            \
  441.     Q3_METHOD_TYPE('g','s','t','d')
  442. typedef TQ3Status (*TQ3XGroupStartIterateMethod)(
  443.     TQ3GroupObject        group,
  444.     TQ3GroupPosition    *iterator,
  445.     TQ3Object             *object,
  446.     TQ3ViewObject        view);
  447.  
  448. #define kQ3XMethodType_GroupEndIterate                \
  449.     Q3_METHOD_TYPE('g','i','t','d')
  450. typedef TQ3Status (*TQ3XGroupEndIterateMethod)(
  451.     TQ3GroupObject        group,
  452.     TQ3GroupPosition    *iterator,
  453.     TQ3Object             *object,
  454.     TQ3ViewObject        view);
  455.  
  456. /*
  457.  *    IO  Helpers
  458.  *    
  459.  *    TQ3XGroupEndReadMethod
  460.  *        Called when a group has been completely read. Group should perform
  461.  *        validation and clean up any reading caches.
  462.  */
  463. #define kQ3XMethodType_GroupEndRead                    \
  464.     Q3_METHOD_TYPE('g','e','r','d')
  465. typedef TQ3Status (*TQ3XGroupEndReadMethod)(
  466.     TQ3GroupObject        group);
  467.  
  468.  
  469. QD3D_EXPORT void *Q3XGroup_GetPositionPrivate(
  470.     TQ3GroupObject            group,
  471.     TQ3GroupPosition        position);
  472.     
  473. #ifdef __cplusplus
  474. }
  475.  
  476. #if defined(__MWERKS__)
  477.     #pragma enumsalwaysint reset
  478. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  479.     #pragma options enum=reset
  480. #endif
  481.  
  482. #endif /*  __cplusplus  */
  483.  
  484. #endif /*  QD3DGroup_h  */
  485.